<?php
$section = "contact";
$titre = _LB_CONTACT;
$link = $section;
Session::setBackLink($link);
//create cfer
$cfer = new Cfer(array(
	_LB_HOME => APPLICATION_URL_FO,
    _LB_CONTACT => APPLICATION_URL_FO."/contact/contact-form/"
));
$send = Request::get("actionContact");

if($send=="send"){
    $name = Request::get("txtfullname");
    $email = Request::get("txtemail");
    $phone = Request::get("txtphone");
    $address = Request::get("txtaddress");
    $description = Request::get("txtdes");
    if($name!="" && $email!="" && $phone!="" && $description!=""){
        $html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                    <td>'._LB_FULL_NAME.'</td>
                    <td style="padding-bottom:3px">'.$name.'</td>
                    </tr>
                    <tr>
                    <td>'._LB_EMAIL.'</td>
                    <td style="padding-bottom:3px">'.$email.'</td>
                    </tr>
                    <tr>
                    <td>'._LB_ADDRESS.'</td>
                    <td style="padding-bottom:3px">'.$address.'</td>
                    </tr>
                    <tr>
                    <td>'._LB_PHONE.'</td>
                    <td style="padding-bottom:3px">'.$phone.'</td>
                    </tr>
                    <tr>
                    <td >'._LB_CONTENT.'</td>
                    <td style="padding-bottom:3px">'.$description.'</td>
                    </tr>
                </table>';
        $subject = "Someone has just sent you an email by contact form!";
        include 'mail.php';
        $mail = new html_mime_mail("X-Mailer: Html Mime Mail Class");
		$mail->add_html($html, "");
		$mail->set_charset("utf-8", TRUE);
		$mail->build_message();
		//-- Function send to mail
		//send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '')
		$mail->send("Administrator",CONTACT_EMAIL,$name,$email,$subject,"");
        redirect(APPLICATION_URL_FO."/page/contact_sent/");
    }
}
$code = Request::get("code");
$page = new Static_Page();
$page->query("SELECT * FROM STATIC_PAGE WHERE CODE = 'contact'");
$page->fetch();
Session::setBackCfer($link, $cfer->getCferArray());
$smarty->assign('cfer', $cfer);
$smarty->assign('page', $page);
$smarty->assign('titre', $titre);
$smarty->assign('META_TAG_KEYWORD', ($page->META_KEYWORD == ""? META_TAG_KEYWORD: $page->META_KEYWORD));
$smarty->assign('META_TAG_DESCRIPTION', ($page->META_DESCRIPTION == ""? META_TAG_DESCRIPTION: $page->META_DESCRIPTION));
$smarty->display("contact_form.html");